package org.library.menu;

import org.springframework.beans.factory.BeanFactory;
import org.springframework.stereotype.Component;

/**
 * 入口菜单
 *
 * @author Chen
 * @since 2023/6/13 14:33
 */

@Component
public class MainMenu extends Menu {

    public MainMenu(BeanFactory beanFactory) {
        super(beanFactory);
    }

    @Override
    public void menu() {
        System.out.println("欢迎使用图书管理系统");
        System.out.println("1.登录");
        System.out.println("2.注册");
        System.out.println("3.退出");
        System.out.println("请输入你的选择：");
        String select = scanner.next();
        switch (select) {
            case "1":
                library.setMenu(beanFactory.getBean(LoginMenu.class));
                break;
            case "2":
                library.setMenu(beanFactory.getBean(RegisterMenu.class));
            case "3":
                System.out.println("欢迎下次使用");
                return;
            default:
                break;
        }
        library.run();
    }
}
